

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Ex1
 */
@WebServlet("/Ex1")
public class Ex1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Ex1() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer numero = Integer.parseInt(request.getParameter("numero"));
		PrintWriter out;
		try {
			out = response.getWriter();
			response.setContentType("text/html");
			
			out.println("<html><body>");
			out.println("<h1>Resultado</h1>");
			
			if (numero != null) {
				int linha=0;
				out.println("<table border=1>");
				
				for (int i = 0; i < 10; i++) {
					out.println("<tr>");
					out.println("<td>");
						out.println(numero);
					out.println("</td>");
					out.println("<td>");
						out.println("x");
					out.println("</td>");
					out.println("<td>");
						out.println(i+1);
					out.println("</td>");
					out.println("<td>");
						out.println("=");
					out.println("</td>");
					out.println("<td>");
						out.println(numero * (i+1));
					out.println("</td>");
				out.println("</tr>");
				}
				
				out.println("</table>");
			} else {
				out.println("<h3>Parâmetros ausentes!</h3>");
			}
			out.println("</body></html>");
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
